package com.example.controller.user;

import com.example.domain.user.dto.UserSubmitDTO;
import com.example.domain.vo.UserQuestionResultVO;
import com.example.service.user.IUserQuestionService;
import oj.common.core.controller.BaseController;
import oj.common.core.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {
    //这里直接调用判题的微服务
    @Autowired
    private IUserQuestionService userQuestionService;
    //这个类只是来进行将类型和一些参数给判题功能
    //用户代码提交   请求方法  地址  参数  响应数据结构
    @PostMapping("/submit")
    public Result<UserQuestionResultVO> submit(@RequestBody UserSubmitDTO userbmitDTO) {
        return userQuestionService.submit(userbmitDTO);
    }
    @PostMapping("/rabbit/submit")
    public Result<Void> rabbitmqSubmit(@RequestBody UserSubmitDTO userbmitDTO) {
        return  toResult(userQuestionService.rabbitmqSubmit(userbmitDTO));
    }
    @GetMapping("/exe/result")
    public  Result<UserQuestionResultVO> exeResult(Long examId, Long questionId, String currentTime) {
        return Result.success(userQuestionService.exeResult(examId, questionId, currentTime));
    }
}
